#! /usr/bin/env node


const program = require('commander');
const inquirer = require('inquirer');//引入包
const superagent = require('superagent');

let answers = [
    {
        type: 'input',
        name: 'from',
        message: '请输入单词：',
        basePath: './src'
    }
];
//定义要展示的格式
program
    .version('1.0.0')
    .action(() => {
        inquirer.prompt(answers).then(function (answers) {
            // (answers.from is the path chosen)
            //判断输入的数据是什么
            //console.log(answers.from)
            // if(answers.from=="我喜欢你"){//判断输入的数据   来输出对应的答案
            //     console.log(answers.from)
            //     console.log("I like you")
            // }else if(answers.from=="do u like me?"){
            //     console.log(answers.from)
            //     console.log("你喜欢我吗?")
            // }else if(answers.from=="yes i do"){
            //     console.log(answers.from)
            //     console.log("是的我做到了")
            // }else if(answers.from=="i want kiss u"){
            //     console.log(answers.from)
            //     console.log("我想要吻你")
            // }
            superagent
                .get('http://fanyi.youdao.com/openapi.do?keyfrom=toaijf&key=868480929&type=data&doctype=json&version=1.1')
                .query({ q: answers.from })  // sends a JSON post body
                .end((err, res) => {
                   console.log(res.body.translation[0])
                });
        });
    })

program.parse(process.argv);